package mudfox.controller;

import mudfox.entity.Result;
import mudfox.support.DateUtil;

import java.util.List;
import java.util.ArrayList;

public class BaseController {
    protected String entry;
    protected List<String> functions;

    public BaseController() {
        entry = getClass().getSimpleName().replace("Controller", "");
        functions = new ArrayList<>();
        functions.add("show_api");
        functions.add("id:id");
        functions.add("post#item");
        functions.add("put#id:id");
        functions.add("delete#id:id");
    }

    public Result show_status() {
        Result item = new Result(entry);
        item.put("time", DateUtil.getDateTimeString());
        item.put("status", "Running");
        return item;
    }

    public Result show_api() {
        Result item = new Result(entry);
        item.put("apis", functions);
        return item;
    }
}
